<!DOCTYPE html>
<html
  xmlns:th="http://www.thymeleaf.org"
  xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
>
  <head>
    <meta charset="UTF-8" />
    <title>Header</title>
  </head>
  <body>
    <th:block th:fragment="header">
      <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
          <a class="navbar-brand" th:href="@{/}">王铉凯AI简历分析SimpleHire</a>
          <button
            class="navbar-toggler"
            type="button"
            data-bs-toggle="collapse"
            data-bs-target="#navbarNav"
          >
            <span class="navbar-toggler-icon"></span>
          </button>
          <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav me-auto">
              <li class="nav-item">
                <a class="nav-link" th:href="@{/dashboard}">仪表板</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" th:href="@{/interview}">简历分析</a>
              </li>
              <!-- 管理员专属菜单 -->
              <li class="nav-item" sec:authorize="hasRole('ADMIN')">
                <a class="nav-link" th:href="@{/admin/users}">用户管理</a>
              </li>
            </ul>
            <ul class="navbar-nav">
              <li class="nav-item">
                <span
                  class="navbar-text me-3"
                  sec:authorize="isAuthenticated()"
                >
                  欢迎, <span sec:authentication="name"></span>
                  <span
                    sec:authorize="hasRole('ADMIN')"
                    class="badge bg-danger ms-1"
                    >管理员</span
                  >
                </span>
              </li>
              <li class="nav-item" sec:authorize="isAuthenticated()">
                <form th:action="@{/logout}" method="post">
                  <button type="submit" class="btn btn-outline-light btn-sm">
                    退出
                  </button>
                </form>
              </li>
            </ul>
          </div>
        </div>
      </nav>
    </th:block>
  </body>
</html>
